package com.sky.context;
//TreadLocal并不是TreadLocal,而是Thread的局部变量。TreadLocal为每个线程单独提供一份存储空间，线程外无法访问
// 一次请求共用一个线程，所以在jwt拦截器时把获取到的用户id储存在BaseContex
public class BaseContext {

    public static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }

    public static Long getCurrentId() {
        return threadLocal.get();
    }

    public static void removeCurrentId() {
        threadLocal.remove();
    }

}
